// 全局变量
$primary-color: #4361ee;
$secondary-color: #3a86ff;
$accent-color: #4cc9f0;
$success-color: #67C23A;
$warning-color: #E6A23C;
$danger-color: #F56C6C;
$bg-color: #f8f9fa;
$panel-bg: #ffffff;
$border-color: #e6e6e6;
$text-color: #333333;
$text-secondary: #666666;
$gradient-blue: linear-gradient(135deg, #4361ee, #3a86ff);
$gradient-purple: linear-gradient(135deg, #7209b7, #b5179e);
$gradient-green: linear-gradient(135deg, #43aa8b, #90be6d);
$gradient-orange: linear-gradient(135deg, #f8961e, #f9c74f);
$shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
$shadow-md: 0 4px 8px rgba(0, 0, 0, 0.1);
$shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.1);
$radius-sm: 6px;
$radius-md: 10px;
$radius-lg: 16px;

// 全局样式
.dashboard-wrapper {
  min-height: 100vh;
  background-color: $bg-color;
  color: $text-color;
  font-family: "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
  position: relative;
  overflow: hidden;
}

// 动画背景
.animated-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0;

  .wave {
    position: absolute;
    opacity: 0.05;
    border-radius: 50%;

    &.wave-1 {
      top: -100px;
      right: -100px;
      width: 500px;
      height: 500px;
      background: $gradient-blue;
      animation: wave 25s infinite linear;
    }

    &.wave-2 {
      bottom: -150px;
      left: -150px;
      width: 700px;
      height: 700px;
      background: $gradient-purple;
      animation: wave 30s infinite linear reverse;
    }

    &.wave-3 {
      top: 50%;
      left: 50%;
      width: 600px;
      height: 600px;
      background: $gradient-green;
      transform: translate(-50%, -50%);
      animation: pulse 15s infinite ease-in-out;
    }
  }

  .geometric-shape {
    position: absolute;
    opacity: 0.03;

    &.shape-1 {
      top: 15%;
      left: 10%;
      width: 100px;
      height: 100px;
      background: $primary-color;
      transform: rotate(45deg);
      animation: float 20s infinite ease-in-out;
    }

    &.shape-2 {
      top: 70%;
      right: 15%;
      width: 150px;
      height: 150px;
      border-radius: 50%;
      background: $secondary-color;
      animation: float 25s infinite ease-in-out reverse;
    }

    &.shape-3 {
      bottom: 10%;
      left: 30%;
      width: 80px;
      height: 80px;
      background: $accent-color;
      clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
      animation: float 18s infinite ease-in-out;
    }

    &.shape-4 {
      top: 25%;
      right: 25%;
      width: 120px;
      height: 120px;
      background: $warning-color;
      clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
      animation: float 22s infinite ease-in-out reverse;
    }
  }

  @keyframes wave {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }

  @keyframes pulse {
    0%, 100% {
      transform: translate(-50%, -50%) scale(1);
    }
    50% {
      transform: translate(-50%, -50%) scale(1.1);
    }
  }

  @keyframes float {
    0%, 100% {
      transform: translateY(0) rotate(0deg);
    }
    25% {
      transform: translateY(-20px) rotate(5deg);
    }
    50% {
      transform: translateY(0) rotate(0deg);
    }
    75% {
      transform: translateY(20px) rotate(-5deg);
    }
  }
}

// 高级头部
.premium-header {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: $panel-bg;
  box-shadow: $shadow-sm;

  .logo-area {
    display: flex;
    align-items: center;

    .logo-icon {
      width: 40px;
      height: 40px;
      border-radius: $radius-md;
      background: $gradient-blue;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-right: 15px;
      box-shadow: $shadow-md;

      .el-icon {
        font-size: 24px;
        color: white;
      }
    }

    .logo-text {
      h1 {
        font-size: 20px;
        font-weight: 600;
        margin: 0;
        color: $text-color;

        span {
          font-weight: 300;
          opacity: 0.7;
        }
      }
    }
  }

  .header-tabs {
    display: flex;
    gap: 10px;

    .tab {
      padding: 8px 16px;
      border-radius: $radius-sm;
      display: flex;
      align-items: center;
      gap: 8px;
      cursor: pointer;
      transition: all 0.3s ease;

      .el-icon {
        font-size: 16px;
        color: $text-secondary;
      }

      span {
        font-size: 14px;
        color: $text-secondary;
      }

      &:hover {
        background: rgba($primary-color, 0.05);

        .el-icon, span {
          color: $primary-color;
        }
      }

      &.active {
        background: rgba($primary-color, 0.1);

        .el-icon, span {
          color: $primary-color;
          font-weight: 500;
        }
      }

      .el-icon, span {
        color: $primary-color;
        font-weight: 500;
      }
    }
  }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;

  .action-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;

    .el-icon {
      font-size: 16px;
    }

    &:hover {
      transform: translateY(-2px);
    }

    &.is-loading {
      .el-icon {
        animation: spin 1s linear infinite;
      }
    }
  }
}

// 主内容区域
.dashboard-content {
  position: relative;
  z-index: 5;
  padding: 20px;
  height: calc(100vh - 70px);
  overflow-y: auto;

  /* 美化滚动条 */
  &::-webkit-scrollbar {
    width: 6px;
  }

  &::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.02);
    border-radius: 3px;
  }

  &::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
  }

  &::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.15);
  }
}

// 统计概览
.stats-overview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 20px;

  .stat-card {
    background: $panel-bg;
    border-radius: $radius-md;
    padding: 20px;
    display: flex;
    position: relative;
    overflow: hidden;
    box-shadow: $shadow-sm;
    border: 1px solid $border-color;
    transition: all 0.3s ease;

    &:hover {
      transform: translateY(-5px);
      box-shadow: $shadow-md;
    }

    &::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 4px;
      transition: all 0.3s ease;
    }

    &.stat-card-1::before {
      background: $gradient-blue;
    }

    &.stat-card-2::before {
      background: $gradient-purple;
    }

    &.stat-card-3::before {
      background: $gradient-green;
    }

    &.stat-card-4::before {
      background: $gradient-orange;
    }

    .stat-icon-wrapper {
      width: 50px;
      height: 50px;
      border-radius: $radius-md;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-right: 15px;
      background: rgba($primary-color, 0.1);

      .el-icon {
        font-size: 24px;
        color: $primary-color;
      }
    }

    .stat-info {
      flex: 1;

      .stat-value {
        font-size: 28px;
        font-weight: 600;
        line-height: 1.2;
        color: $text-color;
      }

      .stat-label {
        font-size: 14px;
        color: $text-secondary;
        margin-bottom: 5px;
      }

      .stat-trend {
        display: flex;
        align-items: center;
        font-size: 12px;

        .el-icon {
          margin-right: 2px;
        }

        .trend-up {
          color: $success-color;
        }

        .trend-down {
          color: $danger-color;
        }

        .trend-neutral {
          color: $text-secondary;
        }
      }
    }

    .stat-chart {
      position: absolute;
      bottom: 0;
      right: 0;
      width: 100px;
      height: 40px;
      opacity: 0.5;
      transition: all 0.3s ease;

      .sparkline {
        width: 100%;
        height: 100%;
      }
    }

    &:hover .stat-chart {
      opacity: 1;
    }
  }
}

// 仪表盘网格
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr;
  gap: 20px;

  .dashboard-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
}

// 面板样式
.dashboard-panel {
  background: $panel-bg;
  border-radius: $radius-md;
  overflow: hidden;
  box-shadow: $shadow-sm;
  border: 1px solid $border-color;
  height: 100%;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;

  &:hover {
    box-shadow: $shadow-md;
  }

  .panel-header {
    padding: 15px 20px;
    border-bottom: 1px solid $border-color;
    display: flex;
    justify-content: space-between;
    align-items: center;

    h3 {
      font-size: 16px;
      font-weight: 500;
      margin: 0;
      color: $text-color;
      display: flex;
      align-items: center;
      gap: 8px;

      .el-icon {
        font-size: 18px;
        color: $primary-color;
      }
    }

    .panel-actions {
      display: flex;
      align-items: center;
      gap: 10px;

      .action-icon {
        font-size: 16px;
        color: $text-secondary;
        cursor: pointer;
        transition: all 0.3s ease;

        &:hover {
          color: $primary-color;
        }
      }
    }
  }

  .panel-body {
    flex: 1;
    padding: 15px;
    display: flex;
    flex-direction: column;

    .chart-container {
      width: 100%;
      height: 100%;
      min-height: 200px;
    }
  }
}

// 学生列表
.student-list {
  display: flex;
  flex-direction: column;
  gap: 10px;

  .student-item {
    background: rgba($primary-color, 0.03);
    border-radius: $radius-sm;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.3s ease;

    &:hover {
      background: rgba($primary-color, 0.08);
      transform: translateX(5px);
    }

    &.top-student {
      background: rgba($primary-color, 0.1);
      border-left: 3px solid $primary-color;
    }

    .student-avatar {
      width: 40px;
      height: 40px;
      border-radius: $radius-sm;
      background: $gradient-blue;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 18px;
      font-weight: bold;
      color: white;
    }

    .student-info {
      flex: 1;

      .student-name {
        font-size: 14px;
        font-weight: 500;
        color: $text-color;
      }

      .student-subject {
        font-size: 12px;
        color: $text-secondary;
      }
    }

    .student-stats {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 5px;

      .student-questions {
        display: flex;
        align-items: center;
        gap: 5px;
        font-size: 12px;
        color: $text-secondary;

        .el-icon {
          font-size: 14px;
          color: $primary-color;
        }
      }

      .student-score {
        display: flex;
        align-items: center;
        gap: 5px;
        font-size: 12px;

        .el-progress {
          width: 60px;
        }
      }
    }
  }
}

// 关键词云
.keywords-cloud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 10px;
  height: 100%;

  .keyword-item {
    border-radius: 20px;
    padding: 6px 12px;
    display: inline-flex;
    align-items: center;
    transition: all 0.3s ease;
    cursor: pointer;
    animation: fadeIn 0.5s ease forwards;
    color: $text-color;

    &:hover {
      transform: scale(1.1) !important;
      box-shadow: $shadow-sm;
    }

    .keyword-count {
      font-size: 0.7em;
      background: rgba(255, 255, 255, 0.3);
      border-radius: 10px;
      padding: 2px 6px;
      margin-left: 5px;
    }
  }

  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: translateY(10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

// 浮动操作按钮
.floating-action-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: $gradient-blue;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: $shadow-lg;
  cursor: pointer;
  z-index: 100;
  transition: all 0.3s ease;

  &:hover {
    transform: scale(1.1);
  }

  .el-icon {
    font-size: 24px;
    color: white;
  }
}

// 学生画像对话框
.student-search-dialog {
  :deep(.el-dialog__header) {
    background: $panel-bg;
    color: $text-color;
    border-bottom: 1px solid $border-color;
  }

  :deep(.el-dialog__body) {
    background: $panel-bg;
    color: $text-color;
    padding: 20px;
  }

  .search-form {
    margin-bottom: 20px;
  }

  .student-profile {
    .profile-header {
      display: flex;
      align-items: center;
      margin-bottom: 20px;

      .profile-avatar {
        width: 60px;
        height: 60px;
        border-radius: $radius-md;
        background: $gradient-blue;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        font-weight: bold;
        color: white;
        margin-right: 15px;
      }

      .profile-title {
        h2 {
          font-size: 20px;
          font-weight: 600;
          margin: 0 0 5px 0;
          color: $text-color;
        }

        .profile-status {
          display: inline-block;
          padding: 4px 10px;
          border-radius: 20px;
          font-size: 12px;
          font-weight: 500;

          &.status-excellent {
            background: rgba($success-color, 0.1);
            color: $success-color;
          }

          &.status-good {
            background: rgba($warning-color, 0.1);
            color: $warning-color;
          }

          &.status-warning {
            background: rgba($danger-color, 0.1);
            color: $danger-color;
          }

          &.status-normal {
            background: rgba($text-secondary, 0.1);
            color: $text-secondary;
          }
        }
      }
    }

    .profile-content {
      display: grid;
      grid-template-columns: 1fr;
      gap: 20px;

      .profile-stats {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;

        .profile-stat-card {
          background: $panel-bg;
          border-radius: $radius-sm;
          padding: 15px;
          display: flex;
          align-items: center;
          border: 1px solid $border-color;
          box-shadow: $shadow-sm;

          .stat-icon {
            width: 40px;
            height: 40px;
            border-radius: $radius-sm;
            background: rgba($primary-color, 0.1);
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 12px;

            .el-icon {
              font-size: 20px;
              color: $primary-color;
            }
          }

          .stat-details {
            .stat-value {
              font-size: 16px;
              font-weight: 600;
              margin-bottom: 2px;
              color: $text-color;
            }

            .stat-label {
              font-size: 12px;
              color: $text-secondary;
            }
          }
        }
      }

      .profile-charts {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;

        .profile-chart-container {
          background: $panel-bg;
          border-radius: $radius-sm;
          padding: 15px;
          border: 1px solid $border-color;
          box-shadow: $shadow-sm;

          h3 {
            font-size: 16px;
            font-weight: 500;
            margin: 0 0 15px 0;
            text-align: center;
            color: $text-color;
          }

          .profile-chart {
            height: 250px;
          }

          .learning-progress {
            display: flex;
            flex-direction: column;
            gap: 15px;
            padding: 10px;

            .progress-item {
              .progress-label {
                display: flex;
                justify-content: space-between;
                margin-bottom: 5px;
                font-size: 14px;
                color: $text-color;
              }
            }
          }
        }
      }

      .profile-recommendations {
        background: $panel-bg;
        border-radius: $radius-sm;
        padding: 15px;
        border: 1px solid $border-color;
        box-shadow: $shadow-sm;

        h3 {
          font-size: 16px;
          font-weight: 500;
          margin: 0 0 15px 0;
          color: $text-color;
        }

        .recommendation-list {
          display: flex;
          flex-direction: column;
          gap: 12px;

          .recommendation-item {
            display: flex;
            align-items: flex-start;
            gap: 12px;
            padding: 10px;
            border-radius: $radius-sm;
            background: rgba($primary-color, 0.03);

            .recommendation-icon {
              width: 36px;
              height: 36px;
              border-radius: $radius-sm;
              background: rgba($primary-color, 0.1);
              display: flex;
              align-items: center;
              justify-content: center;

              .el-icon {
                font-size: 18px;
                color: $primary-color;
              }
            }

            .recommendation-content {
              flex: 1;

              .recommendation-title {
                font-size: 14px;
                font-weight: 500;
                margin-bottom: 4px;
                color: $text-color;
              }

              .recommendation-desc {
                font-size: 12px;
                color: $text-secondary;
                line-height: 1.5;
              }
            }
          }
        }
      }
    }
  }

  .no-profile-data {
    text-align: center;
    padding: 40px 0;

    .el-icon {
      font-size: 48px;
      color: $text-secondary;
      margin-bottom: 15px;
    }

    h3 {
      font-size: 18px;
      font-weight: 500;
      margin: 0 0 10px 0;
      color: $text-color;
    }

    p {
      font-size: 14px;
      color: $text-secondary;
      margin: 0;
    }
  }
}

// 无数据状态
.no-data {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: $text-secondary;

  .el-icon {
    font-size: 24px;
    margin-bottom: 10px;
  }

  span {
    font-size: 14px;
  }
}

// 动画
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

// 响应式调整
@media (max-width: 1400px) {
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;

    .right-column {
      grid-column: span 2;
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 20px;
    }
  }
}

@media (max-width: 992px) {
  .stats-overview {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-grid {
    grid-template-columns: 1fr;

    .right-column {
      grid-column: span 1;
      display: flex;
      flex-direction: column;
    }
  }

  .student-profile {
    .profile-content {
      .profile-charts {
        grid-template-columns: 1fr;
      }
    }
  }

  .header-tabs {
    display: none;
  }
}

@media (max-width: 768px) {
  .premium-header {
    .logo-text {
      h1 {
        font-size: 16px;
      }
    }

    .header-actions {
      .action-btn {
        span {
          display: none;
        }
      }
    }
  }

  .stats-overview {
    grid-template-columns: 1fr;
  }

  .student-profile {
    .profile-header {
      flex-direction: column;
      text-align: center;

      .profile-avatar {
        margin-right: 0;
        margin-bottom: 10px;
      }
    }

    .profile-content {
      .profile-stats {
        grid-template-columns: 1fr;
      }
    }
  }
}